﻿using System.Collections.Generic;
using System.ServiceModel;
using VMukti.Business.CommonDataContracts;
using VMukti.Business.WCFServices.BootStrapServices.DataContracts;
using System.Data;

namespace VMukti.Business.WCFServices.SuperNodeServices.BasicHttp
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class DataBaseDelegates : IHttpDataBaseService
    {
        public delegate void DelHttpsvcJoin();
        public delegate clsDataBaseInfo DelHttpExecuteDataSet(string querystring);
        public delegate clsDataBaseInfo DelHttpExecuteStoredProcedure(string spName, clsSqlParameterContract objSParam);
        public delegate void DelHttpExecuteNonQuery(string spName, clsSqlParameterContract objSParam);
        public delegate int DelHttpExecuteReturnNonQuery(string spName, clsSqlParameterContract objSParam);

        public event DelHttpsvcJoin EntHttpsvcjoin;
        public event DelHttpExecuteDataSet EntHttpExecuteDataSet;
        public event DelHttpExecuteStoredProcedure EntHttpExecuteStoredProcedure;
        public event DelHttpExecuteNonQuery EntHttpExecuteNonQuery;
        public event DelHttpExecuteReturnNonQuery EntHttpExecuteReturnNonQuery;
        

        public void svcJoin()
        {
            if (EntHttpsvcjoin != null)
            {
                EntHttpsvcjoin();
            }
        }

        public clsDataBaseInfo svcExecuteDataSet(string querystring)
        {
            if (EntHttpExecuteDataSet != null)
            {
                return EntHttpExecuteDataSet(querystring);
            }
            else
            {
                return null;
            }
        }

        public clsDataBaseInfo svcExecuteDataSet(string spName,clsSqlParameterContract objSParam)
        {
            if (EntHttpExecuteStoredProcedure != null)
            {
                return EntHttpExecuteStoredProcedure(spName, objSParam);
            }
            else
            {
                return null;
            }
        }

        public void svcExecuteNonQuery(string spName, clsSqlParameterContract objSParam)
        {
            if (EntHttpExecuteNonQuery != null)
            {
                EntHttpExecuteNonQuery(spName, objSParam);
            }           
        }

        public int svcExecuteReturnNonQuery(string spName, clsSqlParameterContract objSParam)
        {
            if (EntHttpExecuteReturnNonQuery != null)
            {
                return EntHttpExecuteReturnNonQuery(spName, objSParam);
            }
            else
            {
                return -1;                
            }
        }

    }
}
